package com.qq.mall.config;

import com.alipay.api.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AlipayClientConfig {
    @Bean
    public AlipayClient alipayClient() throws AlipayApiException {

        AlipayConfig alipayConfig = new AlipayConfig();

        //设置网关地址
        alipayConfig.setServerUrl("https://openapi.alipaydev.com/gateway.do");
        //设置应用Id
        alipayConfig.setAppId("2021000122680655");
        //设置应用私钥
        alipayConfig.setPrivateKey("MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCca3S/Mhm7Y+Fh5scDlQLH+ccQhriP0Ar9SHc7tT/FOrS4ztDp6fhQOA/9Xst+0JB1PHvC+JDzCVnIwTBqyhRlBjBk6rxdNTBj8Cngy7gLlHt8bcdt5aIQCTFMLciZyW+PyYTyj9rfnCqdBKhX/0kf4wcFSHLED9P8Bo8vuO3erUFv7tqua7wWWuAjLpuNfASZsNvMoPUtF6AraV8L+tMY9lxgO4RihV4FUo9DBVJeqynUlgb0Y/hYFjPMu8NHzSKpA2m0wG2N0cNxJ7Vjw1AM+7vwC4xZRRLag2VGnuKujyeYWaF3Z9AoHJCVghVRy6f6DKQ4peRQ/Eh7V/KMuXCjAgMBAAECggEALuskh701broU/tLEW1S1EtrfVRuz/J9AzJyR9zz0tepYDx8qFx/xNc67LRrkG1PgIOpVjTQV9nCVl9wq871NxMfIeFzYx3SO4UtGpIE24XJWYAplyZcZt4mqWdlZ1JdReWXPFRsFYhFrztF41XxjqMbmcjU7B4hf47br+DqWTzZcpfo2qjbWDzFiwzZAzlHYpnFT7JnCT5ltSfI+aJgBbRuFkU0XcZqyO6lMDK2FGMuRJZ/hQy1O2o3s/UoMII+iMZKpV6lygnXxCs+FiURvoFdM7C3cr3lSWHp+Uj0dS5g1xzDGUFMHiQu9y6BFCiY4qY3VlJQGi9KxOySWrw1D4QKBgQDUz5ddyLlgd9lO/uTL8TCWZQKi0bchrz7sqjeuhM2QBxbcYIf85Td80MSNLH5aog/FL0GpwrGJLRbuWqe5Qtl1ihcNSZsrerv1oxYswuRloD2LSEOCYuHLZ92ysrv2G1ZCe0EdKbTvufeLRuELtPK0nZIiCsiYxjr9XcvjX2CV+wKBgQC8KhxN7o8CwICn7HW5JuZPSUG2d7oZYTMygpShnoIQwv7MORIXHuNN3KherfyXcWEatqmSrXULfn0M4qIFJBRGddNYdJb4ULPhOZo9yi3Y/YRhAJypf8BDcIAn4GOYJx1E3UBYvcfRqVrsd9T9SasMUM3CxC1sDHHktQeEQXsXeQKBgCFzA6q1CxYzoE9/Vv0LSwTImbJ33h4ISo6ubpQawai6xIgdECLa8G7I7av262FZibsHo32IYZlbIfiS/TvsWvvTma33/NDHuNVyLeEZPQcQObwzvpC29CChkcItv8d+In/Ombx4urzXcSZOHL9XULK89aQuJ7uDpPAAFzUE38yTAoGAYPjW03cBbuqko2YimYQpp2zal94GI7RLPVm8nbphz5+ezsMOxqmdfXAduYWzKp087RZ8N+J68qyCZ9SYqUuZw2JPxEN51olI2ubjzbpXfH/S7GbzVgtHm7nr4iErUqu90tKvqcxMoYnFGR78vnhr1ZIDKMAPpKKZQ8PkFs3kUQkCgYBVqxPxk27nMf5TSVL9LujFdgNWjIW5H4WRv5fuLYf9sh76mYdDH7E9wjcIWtO7iKvwSevdwRrDDc5oJEpGzXal7wWrhrDKz62PwTiHVJK7urFQ9dLI0ltcNy/p1Y42u280bGCPXx51eNF1hT+Z1+YnWhBUBeiS/RJctWU5PwevMA==");
        //设置请求格式，固定值json
        alipayConfig.setFormat(AlipayConstants.FORMAT_JSON);
        //设置字符集
        alipayConfig.setCharset(AlipayConstants.CHARSET_UTF8);
        //设置支付宝公钥
        alipayConfig.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlJJP+vYxbUfYG6Ybos1W112DA43Fe3Xcwu86B3U5HzSSxjjzA0pzPB9ppiZFDTSdJgczllPDEaALCiFVL4543rk7CJXbf0ZDI1tF3qL6Xas70gQaQjyARUUh5pScgYo59qDB1H075+vefU8Qvy9kMSSlhy5wCfD7PtR450bAre95rVvt3UYWX8x86jPuZBsXsioP1VfaMgmuCOlcF0uAUt2W+cSz1KKSCf3GcVjTupW3Yw/5WuFJA+kxH7Vh1p1iEFoZi3b5NNcubon1j/d68y5JRj9oDxoYg0M2iB5YE9+dIz84/ha6HcedT1FYQhAmO3w4H56vGD0n+gc6159iUwIDAQAB");
        //设置签名类型
        alipayConfig.setSignType(AlipayConstants.SIGN_TYPE_RSA2);
        //构造client
        AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig);

        return alipayClient;
    }
}
